package com.pengtu.gsj.dao.check;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.pengtu.gsj.dao.hibernate.HibernateDao;
import com.pengtu.gsj.entity.check.CheckTable;

@Repository
public class CheckTableDao extends HibernateDao<CheckTable, String>{
	
	public CheckTable findCheckTable(String menuId, String projId) {
		String hql = "from CheckTable m where m.menuId=? and m.checkProject.id=? and m.delFlag='0'";
		return this.findUnique(hql, menuId, projId);
	}
	
	public List<CheckTable> getSumSystems(String id, String projId) {
		String hql = "select new com.pengtu.gsj.entity.check.CheckTable(sum(t.testFull),sum(t.tableFull),ROUND(SUM(t.testFull)/SUM(t.tableFull)*100,2)) from CheckTable t where t.checkProject.id =? and t.menuId in"+
				     "(select s.id from Sysmenu s where s.parentIds like ? and s.system ='1' and s.menuType ='0' and s.delFlag='0')";
		return find(hql, projId ,"%"+id+"%");
	}
	
	public List<CheckTable> getAllSum (String projId) {
		String hql = "select new com.pengtu.gsj.entity.check.CheckTable(sum(t.testFull),sum(t.tableFull),ROUND(SUM(t.testFull)/SUM(t.tableFull)*100,2)) from CheckTable t where t.checkProject.id =? and t.delFlag='0'";
		return find(hql, projId);
	}
}	
